{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-11-21T01:41:00.206217Z",
     "start_time": "2025-11-21T01:41:00.197476Z"
    }
   },
   "source": [
    "\"\"\"\n",
    "创建一个包含10名学生数学成绩的Series，\n",
    "成绩范围在50-100之间计算平均分、最高分、最低分，\n",
    "并找出高于平均分的学生人数。\n",
    "\"\"\"\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "\n",
    "# 生成随机成绩\n",
    "np.random.seed(42)\n",
    "scores = pd.Series(np.random.randint(50, 101, 10), index=['学生'+str(i) for i in range(1, 11)])\n",
    "\n",
    "# 打印平均分，最小值，最大值\n",
    "print(f\"成绩平均分：\", scores.mean())\n",
    "print(f\"成绩最大值：\", scores.min())\n",
    "print(f\"成绩最小值：\", scores.max())\n",
    "mean = scores.mean()\n",
    "\n",
    "# 高于平均分的学生\n",
    "print(\"高于平均分的学生有：\")\n",
    "print(scores[scores>mean])\n",
    "print(f\"高于平均分的学生人数是：\", scores[scores>mean].count())"
   ],
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "成绩平均分： 73.7\n",
      "成绩最大值： 57\n",
      "成绩最小值： 92\n",
      "高于平均分的学生有：\n",
      "学生1    88\n",
      "学生2    78\n",
      "学生4    92\n",
      "学生7    88\n",
      "dtype: int32\n",
      "高于平均分的学生人数是： 4\n"
     ]
    }
   ],
   "execution_count": 14
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
